<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Locale extends Model
{
  /**
   * Insert validation rules.
   *
   * @var array
   */
  public static $insertRules = [
    'country_id' => 'required|int',
    'language_id' => 'required|int',
    'code' => 'required|min:5|unique:locales',
    'name' => 'required|max:255',
    'active' => 'nullable|boolean',
  ];

  /**
   * Update validation rules.
   *
   * @var array
   */
  public static $updatetRules = [
    'country_id' => 'nullable|int',
    'language_id' => 'nullable|int',
    'code' => 'nullable|min:5|unique:locales',
    'name' => 'nullable|max:255',
    'active' => 'nullable|boolean',
  ];
  /**
   * The attributes that are mass assignable.
   *
   * @var array
   */
  protected $fillable = [
    'country_id',
    'language_id',
    'code',
    'name',
    'active',
  ];

  /**
   * The attributes excluded from the model's JSON form.
   *
   * @var array
   */
  protected $hidden = [
    'country_id',
    'language_id',
  ];

  /**
   * The attributes that should be cast to native types.
   *
   * @var array
   */
  protected $casts = [];

  /**
   * Relationship with countries.
   */
  public function country()
  {
    return $this->belongsTo(Country::class);
  }

  /**
   * Relationship with languages.
   */
  public function language()
  {
    return $this->belongsTo(Language::class);
  }
}
